package cn.iocoder.yudao.module.api.member.task.enums;

import cn.iocoder.yudao.framework.business.basic.enums.EnumCodable;
import com.baomidou.mybatisplus.annotation.EnumValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;
import java.util.stream.Stream;

/**
 * 任务业务类型枚举
 */
@Getter
@AllArgsConstructor
public enum TaskBizTypeEnum implements EnumCodable {

    UNKNOWN("undefined", "未知"),
    CRYPTOCURRENCY_INCREMENT("cryptocurrency_increment", "看广告增值联盟豆"),
    LINKAGE21_INVITE("linkage21_invite", "链动2+1拉人"),
    ;

    @EnumValue
    private final String code;
    private final String name;

    @Override
    public String toString() {
        return new ViewObject(code, name).toString();
    }

    public static TaskBizTypeEnum codeOf(String code) {
        return Stream.of(values())
                .filter(p -> Objects.equals(p.code, code))
                .findAny()
                .orElse(UNKNOWN);
    }

}
